﻿using System;
using System.Data;
using System.Data.SqlClient;
using PPIProxy.PPIWebservice;
namespace PPIProxy
{
    public class WVendor_Visit_XMissionStructures_Image
    {


        #region Query

        public static DataSet GetServerImages(int offset, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            return serv.Vendor_Visit_XMissionStructures_Image_GetServerImages(offset, connectionKey);
        }

        public static DataSet GetByStructureID(int structureID, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            return serv.Vendor_Visit_XMissionStructures_Image_GetByStructureID(structureID, connectionKey);
        }

        public static int VerifyExistence(int imageID, int poleId, int structureID, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            return
                serv.Vendor_Visit_XMissionStructures_Image_VerifyExistence(imageID, poleId, structureID, connectionKey);
        }

        public static int GetFreePosition(int imageID, int structureID, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            return serv.Vendor_Visit_XMissionStructures_Image_GetFreePosition(imageID, structureID, connectionKey);
        }

        public static int GetTotal(string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            return serv.Vendor_Visit_XMissionStructures_Image_GetTotal(connectionKey);
        }

        #endregion Query

        #region Crud

        public static int Insert(int vendor_Visit_XMissionStructureFK, bool solutionAvaible, string fileName, byte[]bytes, double latitude, double altitude, double longitude, DateTime satelliteTime, int satelliteCount, double direction, int vendor_Visit_XMissionStructures_PoleID,string connectionKey )
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();

             int _ImageId =   serv.Vendor_Visit_XMissionStructures_Image_Insert(vendor_Visit_XMissionStructureFK, solutionAvaible,
                                                                  fileName, bytes, latitude, altitude, longitude,
                                                                  satelliteTime, satelliteCount, direction,
                                                                  vendor_Visit_XMissionStructures_PoleID,connectionKey);
            return _ImageId;
            

        }

        public static bool SaveFile(string destinationFile, byte[] bytes)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            return serv.SaveImage(destinationFile, bytes);
        }

        public static void InsertExistingImage(bool solutionAvaible, string fileName, double latitude, double altitude, double longitude, DateTime satelliteTime, int satelliteCount, double direction, int vendor_Visit_XMissionStructures_PoleID, int originalImageId, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            serv.Vendor_Visit_XMissionStructures_Image_InsertExistingImage(solutionAvaible, fileName, latitude, altitude,
                                                                           longitude, satelliteTime, satelliteCount,
                                                                           direction,
                                                                           vendor_Visit_XMissionStructures_PoleID,
                                                                           originalImageId, connectionKey);
        }

        public static void UpdatePoleReference(bool solutionAvaible, double latitude, double altitude, double longitude, DateTime satelliteTime, int satelliteCount, double direction, int vendor_Visit_XMissionStructures_PoleID, int originalImageId, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            serv.Vendor_Visit_XMissionStructures_Image_UpdatePoleReference(solutionAvaible, latitude, altitude,
                                                                           longitude, satelliteTime, satelliteCount,
                                                                           direction,
                                                                           vendor_Visit_XMissionStructures_PoleID,
                                                                           originalImageId, connectionKey);
        }

        public static void Delete(int imageID, string connectionKey)
        {
            PPIProxy.PPIWebservice.PPIWebServiceClass serv = new PPIService();
            serv.Vendor_Visit_XMissionStructures_Image_Delete(imageID, connectionKey);
        }

        #endregion

        
    }
}
